package com.example.messagemodule.widget;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.util.AttributeSet;
import android.widget.LinearLayout;

import androidx.annotation.Nullable;

import com.example.messagemodule.R;

@SuppressLint("AppCompatCustomView")
public class MessageVoiceBackgroundGreenRight extends LinearLayout {
    public MessageVoiceBackgroundGreenRight(Context context) {
        super(context);
    }

    public MessageVoiceBackgroundGreenRight(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public MessageVoiceBackgroundGreenRight(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
        paint.setColor(getResources().getColor(R.color.color_94EB68));
        paint.setStrokeWidth(5);
        paint.setStyle(Paint.Style.FILL);

        int width = getWidth();
        int height = getHeight();

        Path path = new Path();
        path.moveTo(30, 0);
        path.quadTo(30, 0, 0, 30);
        path.lineTo(0, height-60);
        path.quadTo(0, height-60, 30, height-30);
        path.lineTo(width-150, height-30);
        path.lineTo(width-135, height);
        path.lineTo(width-120, height-30);
        path.lineTo(width-30, height-30);
        path.quadTo(width-30, height-30, width, height-60);
        path.lineTo(width, height-60);
        path.lineTo(width, 30);
        path.quadTo(width, 30, width-30, 0);
        path.lineTo(30, 0);
        //X、Y坐标，radius半径
        canvas.drawCircle(30, 30, 30, paint);
        canvas.drawCircle(30, height-60, 30, paint);
        canvas.drawCircle(width-30, height-60, 30, paint);
        canvas.drawCircle(width-30, 30, 30, paint);
        path.close();
        canvas.drawPath(path, paint);
    }
}
